<?php
$T->loadTpl("./html/".$template."/".$qname.".html");
$T->SetTpl('cssjs','html/cssjs.inc'); 
$T->SetTpl('jsmodel','html/jsmodel.inc');

$name=isset($_GET["name"])?$_GET["name"]:"";
$p=isset($_GET["p"])?$_GET["p"]:"0";
$seach_where="";
if(!empty($name)){
	$seach_where="where name like '%".$name."%'";
}
if($p<1)$p=1;
$rc=$T->db->query("select count(*) from sys_equipment_repair ".$seach_where)->fetchColumn(0);

$page=getPageHtml_bt($rc,15,$p,"&t=repair_type&name=".$name);
$page=mb_convert_encoding($page, 'utf-8', 'utf-8');
$T->Set("is_list",$rc);
$T->Set("p",$p);
$T->Set("page",$page);
$T->Set("name",$name);
$arr=$T->db->query("select * from sys_equipment_repair ".$seach_where." order by id asc limit ".(($p-1)*15).",15")->fetchAll();
$html='';
foreach($arr as $v){
	$user_str=$T->db->query("select repair_user_id from sys_equipment_repair where id=".$v['id'])->fetchColumn(0);
	$user_arr=explode(",",$user_str);
	$name_arr=array();
	foreach($user_arr as $val){
		$user_name=$T->db->query("select truename from sys_member where id='".$val."'")->fetchColumn(0);
		$name_arr[]=$user_name;
	}
	$name_str=join(",",$name_arr);
	$html.=<<<EOF
	<tr>
		<td>
			<input type="checkbox" name="checkbox" lay-skin="primary" value="{$v['id']}"/>
		</td>
		<td>{$v['id']}</td>
		<td>{$v['name']}</td>
		<td>{$name_str}</td>
		<td>
			<button class="layui-btn layui-btn-mini modal-iframe" data-opt="update" data-id="{$v['id']}">
				<i class="iconfont">&#xe653;</i>编辑
			</button>
			<button class="layui-btn layui-btn-mini layui-btn-danger ajax" data-opt="del"  data-id="{$v['id']}">
				<i class="iconfont">&#xe626;</i>删除
			</button></td>
		</td>
	</tr>
EOF;
}
if(empty($html)){
	$html ="暂时没有数据";
}
$T->Set("html",$html);


$T->Set("template",$template);         
$T->clearNaN();       
$T->clearNoN();
$T->display(); 